package com.zc.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.zc.dao.ITemDao;
import com.zc.domain.DoubleListData;
import com.zc.domain.FaultItem;
import com.zc.domain.FourPointsItem;
import com.zc.domain.Item;
import com.zc.domain.TwoPointsItem;
import com.zc.service.TemService;
import com.zc.service.RedisService;

@Controller
public class TemController {
	@Autowired
	private TemService temService;
	@Autowired
	private RedisService redisService;
	
	@RequestMapping(value = "/getSubTemperature",method = RequestMethod.POST)
    public @ResponseBody List<FourPointsItem> getSubTemperature(){       	
		String key="subTemperatureData";
		List<FourPointsItem> subTemperatureData=null;
		if(redisService.hasKey(key)){
			subTemperatureData=(List<FourPointsItem>) redisService.get(key);
		}		
		else {
			subTemperatureData=temService.getSubTemperature();
			redisService.set(key, subTemperatureData);
		}
		return subTemperatureData;
    }
	
	@RequestMapping(value = "/getMainTemperature",method = RequestMethod.POST)
    public @ResponseBody List<FourPointsItem> getMainTemperature(){       	
		String key="mainTemperatureData";
		List<FourPointsItem> mainTemperatureData=null;
		if(redisService.hasKey(key)){
			mainTemperatureData=(List<FourPointsItem>) redisService.get(key);
		}		
		else {
			mainTemperatureData=temService.getMainTemperature();
			redisService.set(key, mainTemperatureData);
		}
		return mainTemperatureData;
    }

}
